Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge_tools: create builtin diff editor #2117

Merged
merged 1 commit into from
Aug 30, 2023
Merged

merge_tools: create builtin diff editor #2117

merged 1 commit into from
Aug 30, 2023

Conversation

arxanas
Copy link
Collaborator

@arxanas arxanas commented Aug 19, 2023

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@arxanas arxanas force-pushed the arxanas/difftool-1 branch from c4fceae to a73431b Compare August 19, 2023 21:13
@arxanas arxanas force-pushed the arxanas/difftool-2 branch from 803d4a4 to 0f96d3b Compare August 19, 2023 21:13
cli/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what's the benefit of API-level integration?

It's really nice that we have an integrated diff/merge editor, but I think it could also be achieved by spawning a separate binary or hidden jj subcommand (like jj scm-diff-editor.) Since we can't drop support for external tools, using the existing entry point might be simpler.

cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
@ilyagr
Copy link
Collaborator

ilyagr commented Aug 20, 2023

As an aside, I am wondering about using scm-diff-editor or something like it as a file selector for external diff tools and merge tools that don't have good support for directory comparison like p4merge, vimdiff (though there are other workarounds there), VS Code, etc.

This is related to a suggestion I once made on Discord to allow scm-diff-editor to launch external difftools.

OTOH, we could go into the opposite direction and use something much simpler than scm-diff-editor, e.g. https://github.com/lotabout/skim#use-as-a-library.

@arxanas
Copy link
Collaborator Author

arxanas commented Aug 21, 2023

Out of curiosity, what's the benefit of API-level integration?

It's really nice that we have an integrated diff/merge editor, but I think it could also be achieved by spawning a separate binary or hidden jj subcommand (like jj scm-diff-editor.) Since we can't drop support for external tools, using the existing entry point might be simpler.

@yuja I want to integrate scm-record more tightly with jj, in particular:

  • To support splitting into any number of commits, not just two.
  • To edit commit messages inline (launch JJ_EDITOR or whatever).

Also, you could potentially avoid materializing large (binary?) files on disk, since they're only rendered as hashes in the UI.

We don't have an interface to communicate that kind of thing with the difftool/mergetool, and, since no other tools support anything like that (as far as I know?), it would just slow down development to try to create a stable command-line interface to do all that. We can establish an interface later if someone else ever tries to make such a tool.

As an aside, I am wondering about using scm-diff-editor or something like it as a file selector for external diff tools and merge tools that don't have good support for directory comparison like p4merge, vimdiff (though there are other workarounds there), VS Code, etc.

@ilyagr That sounds reasonable and in-scope to me, although scm-record might have to recompute a diff in that case in order to render it after delegating to the external difftool. Computing a new diff could be a little involved because the VCS can often compute more sensible diffs than scm-record (it may know to ignore whitespace, etc., on the request of the user). I suppose that's another scenario where tight coupling between the VCS and scm-record would help.

OTOH, we could go into the opposite direction and use something much simpler than scm-diff-editor, e.g. https://github.com/lotabout/skim#use-as-a-library.

Skim will probably be better indefinitely for keyboard shortcuts and fuzzy-matching, since it's hard to get good UX for that kind of thing (e.g. supporting Vim, Emacs, OS keybindings in text areas), and it's hard to compose TUI tools/libraries in Rust-land (can't just embed Skim into the scm-record interface somehow). It would be ideal to be able to search through files (and file contents) in scm-record, but there are only so many hours in the day!

@arxanas arxanas force-pushed the arxanas/difftool-1 branch from a73431b to 759e27b Compare August 21, 2023 00:20
@arxanas arxanas force-pushed the arxanas/difftool-2 branch 2 times, most recently from 144b08d to a06f030 Compare August 21, 2023 03:57
@arxanas arxanas force-pushed the arxanas/difftool-1 branch from 759e27b to b549f67 Compare August 22, 2023 04:34
@arxanas arxanas force-pushed the arxanas/difftool-2 branch 2 times, most recently from 715b590 to a375859 Compare August 23, 2023 04:20
@arxanas arxanas force-pushed the arxanas/difftool-1 branch from b549f67 to 7226334 Compare August 23, 2023 04:20
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/internal.rs Outdated Show resolved Hide resolved
Base automatically changed from arxanas/difftool-1 to main August 24, 2023 04:11
@arxanas arxanas marked this pull request as draft August 25, 2023 19:41
@arxanas arxanas changed the title merge_tools: create internal difftool merge_tools: create builtin difftool Aug 27, 2023
@arxanas arxanas changed the base branch from main to arxanas/difftool-1 August 27, 2023 13:44
@arxanas arxanas marked this pull request as ready for review August 27, 2023 13:48
@arxanas arxanas force-pushed the arxanas/difftool-2 branch from a375859 to ee77c67 Compare August 27, 2023 13:49
@arxanas arxanas force-pushed the arxanas/difftool-1 branch 2 times, most recently from d434c1e to 9533a19 Compare August 27, 2023 15:43
@arxanas arxanas force-pushed the arxanas/difftool-2 branch from ee77c67 to 3e26b49 Compare August 27, 2023 15:43
@arxanas arxanas requested a review from martinvonz August 27, 2023 15:45
@arxanas
Copy link
Collaborator Author

arxanas commented Aug 27, 2023

This commit will probably need another look for the latest MergedTree changes.

cli/src/merge_tools/builtin.rs Outdated Show resolved Hide resolved
cli/src/merge_tools/builtin.rs Outdated Show resolved Hide resolved
Cargo.lock Outdated Show resolved Hide resolved
@arxanas arxanas changed the title merge_tools: create builtin difftool merge_tools: create builtin diff editor Aug 28, 2023
@arxanas arxanas marked this pull request as draft August 28, 2023 21:08
@arxanas arxanas force-pushed the arxanas/difftool-2 branch from 3e26b49 to 82f2e6b Compare August 29, 2023 21:13
@arxanas arxanas force-pushed the arxanas/difftool-1 branch from 9533a19 to 50f6e06 Compare August 29, 2023 21:13
@arxanas arxanas marked this pull request as ready for review August 29, 2023 21:14
Base automatically changed from arxanas/difftool-1 to main August 30, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants